"""
https://docs.python.org/3/library/random.html#module-random


random模块：随机
1.random(),获取一个[0,1）之间的小数，
2.randint(a, b),获取一个[a,b]的整数, a小于等于b
    a <= num <= b
3.uniform(a,b),获取一个[a,b]的小数。
    a <= num <= b
    b <= num <= a
4.randrange(start,stop,step),获取指定范围的随机数。范围是 根据起始值，结束值，以及步长，计算来的。

5.random.choice(sequence)序列中获取随机内容
    sequence：字符串，列表，元组

6.random.shuffle(list),列表打乱

7.random.sample(list,个数),取样
"""

import random, sys

print(random.random())  # Random float:  0.0 <= x < 1.0
# print(sys.path)

# randint(a, b) []
print(random.randint(2, 3))

# print(random.uniform(2, 7))
#
print(random.randrange(2, 3))

print(random.choice(['win', 'lose', 'draw']))

# random.choices(population, weights=None, *, cum_weights=None, k=1)¶

print(random.choices(['red', 'black', 'green'], [18, 18, 18], k=7))

list1 = [x for x in range(10)]
# print(list1)
# random.shuffle(list1)
# print(list1)
# print(list1[::-1])
# list1.reverse()
# print(list1)
# print(reversed(list1))
# for i in reversed(list1):
#     print(i)

print(random.sample(list1, 2))

# 用random() 生成50-60 的小数
# 三个色子,掷筛子,点大小,每个筛子是多少

list2 = [x for x in range(1, 7)]
res = random.choices(list2, k=3)
# print(type(res))
print(res)
print(sum(res))


# def getnum(a, b):
#     return random.random() * (b - a) + a
#
#
# print(getnum(50, 60))
# print(int(getnum(50, 60)))
